package com.logging;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import com.clsfd.charging.ChargeCustomer;
import com.clsfd.charging.ChargeEvent;
import com.clsfd.charging.ChargeStatus;
import com.clsfd.database.DatabaseConnection;
import com.clsfd.database.Subscription;
import com.clsfd.database.SystemParams;
import com.clsfd.sms.SMSHandler;
import com.logging.DcLogFormatter;


public class LoggerExample {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 * @throws SQLException 
	 * @throws URISyntaxException 
	 * @throws InterruptedException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException, IOException, SQLException, URISyntaxException, InterruptedException, ClassNotFoundException {
		
		
	     Logger Log=null;
	     DatabaseConnection Databaseconn= null;
		 SMSHandler SmsHandler = null;
	    SystemParams SysParams=null;
	    
		Databaseconn = new DatabaseConnection(null);
    	SysParams = Databaseconn.getSystemParameters();
    	SmsHandler = new SMSHandler(SysParams);    		
        
    	
    	FileHandler filehandler = new FileHandler(SysParams.getSmsHandlerLogFile()+"%g.log",1000000000,3,true);
		Formatter formatterTxt=new DcLogFormatter();
		filehandler.setFormatter(formatterTxt);
		Log = Logger.getLogger("SmsHandler");
		Log.addHandler(filehandler);
		Log.setLevel(Level.parse(SysParams.getSmsHandlerLogLevel()));
		
		
		  while(true)
		  {
			  Log.setLevel(Level.INFO);		  
			  Log.warning("");
			  Log.info("Doing something ...");
			  Log.severe("Doing strictily ");
			  
			  Thread.sleep(1000);
		  }
		 
		  
		 
		
	}

}
